const { BaseCommand } = require("./base");

class JwtDecodeCommand extends BaseCommand {
    async execute() {
        // eyJraWQiOiIxYnh2cE80cGI5TGs1b09HMTZLMlJCIiwiYWxnIjoiRVMyNTYifQ.eyJzdWIiOiJHMUE0Q0VQUkciLCJhdWQiOiJzZWlyZWkiLCJjb3VudHJ5IjoiSlAiLCJjcmVhdGVkIjoxNjY1MzEzMjkwLCJpc3MiOiJnMTIzLWF1dGgiLCJjdXJyZW5jeSI6IkpQWSIsImV4cCI6MTY3Nzk1ODM4NywicmVnaW9uIjoiSlAiLCJsYW5nIjoiamEiLCJpYXQiOjE2Nzc3ODU1ODcsImp0aSI6IjFMbE00UEtuR2VaWWthR0V6YjBhd2wifQ.HXC6wkb7D57I2bdu0Ds_gQp_ZngvjvniP62wJZB5V7pawyVPvnOZT7s_Hkhg9G1hSpoHlAtZKIW5tndlydRBZQ
        const ret = require("jwt-js").decodeToken(this.content);
        // ret = {
        //     "header": {"kid": "1bxvpO4pb9Lk5oOG16K2RB", "alg": "ES256"},
        //     "payload": {"sub": "G1A4CEPRG", "aud": "seirei", "country": "JP", "created": 1665313290, "iss": "g123-auth", "currency": "JPY", "exp": 1677958387, "region": "JP", "lang": "ja", "iat": 1677785587, "jti": "1LlM4PKnGeZYkaGEzb0awl"},
        //     "signature": "HXC6wkb7D57I2bdu0Ds_gQp_ZngvjvniP62wJZB5V7pawyVPvnOZT7s_Hkhg9G1hSpoHlAtZKIW5tndlydRBZQ"
        // };
        return ret;
    }

    getRequireContent() {
        return true;
    }
}

module.exports = {
    JwtDecodeCommand,
};
